package com.x52im.rainbowchat.http.logic;

import com.alibaba.fastjson.JSON;
import com.eva.framework.Processor;
import com.eva.framework.dto.SysActionConst;
import com.eva.framework.utils.EndsExceptionFactory;
import com.x52im.rainbowchat.http.logic.dto.RedEnvelopeDTO;
import com.x52im.rainbowchat.http.logic.pay.redenvelope.*;

public class MoneyProcessor implements SysActionConst, Processor {
    @Override
    public Object process(int job_dispatch_id, int action_id, Object _newData, Object oldData, User user) throws Exception {
        Object ret = null;
        String newDataJSON = (String) _newData;
        RedEnvelopeDTO dto = null;
        switch (job_dispatch_id) {
            case 11: // 发红包
                dto = JSON.parseObject(newDataJSON, RedEnvelopeDTO.class);
                ret = new MRedEnvelopeSend().deal(dto);
                break;
            case 12:// 收红包
                dto = JSON.parseObject(newDataJSON, RedEnvelopeDTO.class);
                ret = new MRedEnvelopeGetFromRedis().deal(dto);
                break;
            case 13:// 查询红包
                dto = JSON.parseObject(newDataJSON, RedEnvelopeDTO.class);
                ret = new MRedEnvelopeQuery().deal(dto);
                break;
            case 14:// 查询账户
                dto = JSON.parseObject(newDataJSON, RedEnvelopeDTO.class);
                ret = new MAccountQuery().deal(dto);
                break;
            default:
                throw EndsExceptionFactory.INVALID_JOB_DISPATCHER_ID(job_dispatch_id);
        }
        return ret;
    }


}
